<?php
namespace App\Controller;
use Think\Controller;
class CommentController extends Controller {
    public function index(){

    }
    public function commentjson(){
    	//周艳军做的显示评论
        $comment=M('comment');
        $allcomment=$comment->select();
        echo json_encode($allcomment);
    	
    }

    public function addcomment($pid,$uid){
    	//周艳军写的添加留言
    	$comment=M('comment');
    	$coid=$_GET['coid'];
    	$uid=$_GET['uid'];
    	$pid=$_GET['pid'];
    	$comment->cdate=date('Y-m-d H:i:s');
    	$content=$_GET['content'];
        $re=$comment->add();	
			if ($re>0)
		    {
		    	$arr=array('info'=>"ture");
				echo json_encode($arr);
			}
			else
			{
				$arr=array('info'=>"false");
				echo json_encode($arr);
			}

    }

    public function delcommentjson($coid){
    	//周艳军写的删除晒图
        $comment=M('comment');

         if (false !== $comment->where("coid=$coid")->delete()) {
            $arr=array('result'=>"ture");
				echo json_encode($arr);
        } else {
            $arr=array('result'=>"false");
				echo json_encode($arr);
        }
}
}